<template>
    <lightning-card
        title="LdsGenerateRecordInputForCreate"
        icon-name="standard:record"
    >
        <div class="slds-var-m-around_medium">
            <template lwc:if={recordInput}>
                <lightning-input
                    label="Name"
                    onchange={handleFieldChange}
                    data-field-name={nameField}
                ></lightning-input>
                <template lwc:if={areaNumberCreateable}>
                    <lightning-input
                        type="number"
                        label="Area Number"
                        onchange={handleFieldChange}
                        data-field-name={areaNumberField}
                        value={areaNumber}
                    ></lightning-input>
                </template>
                <div class="slds-var-m-top_x-small">
                    <lightning-button
                        label="Create Account"
                        variant="brand"
                        onclick={createAccount}
                    ></lightning-button>
                </div>
            </template>
            <template lwc:elseif={error}>
                <c-error-panel errors={error}></c-error-panel>
            </template>
        </div>

        <c-view-source
            source="lwc/ldsGenerateRecordInputForCreate"
            slot="footer"
        >
            Create a custom form with default values and enforcing field
            security using getRecordCreateDefaults and
            generateRecordInputForCreate. Always consider lightning-record-form
            or lightning-record-edit-form first.
        </c-view-source>
    </lightning-card>
</template>
